package com.xxx.test;

import com.xxx.DAO.booksDao;
import com.xxx.DAO.user_bookDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet("/jieshu2")
public class jieshu2 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id=new String(request.getParameter("id").getBytes("iso-8859-1"),"UTF-8");
        int userid = (int) request.getSession().getAttribute("id");
        user_bookDao ubDao=new user_bookDao();
        booksDao bDao=new booksDao();
        ubDao.add(userid,id);
        bDao.updateSum(id);
        request.getRequestDispatcher("showTable").forward(request,response);

    }
}
